﻿using MaterialDesignThemes.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using UIWindow.Commands;
using UIWindow.GlobalParameters;
using UIWindow.Views.Dialogs;

namespace UIWindow.ViewModels
{
    public class DataReportViewModel
    {
        public DataReportGlobal MyDataReportGlobal { get; set; }
        public DataReportViewModel(DataReportGlobal dataReportGlobal)
        {
            MyDataReportGlobal = dataReportGlobal;
        }

        public DelegateCommand<Button> QueryData => new DelegateCommand<Button>(async sender =>
        {
            sender.IsEnabled = false;
            _ = DialogHost.Show(new LoadingDialogs(), "RootDialog").ConfigureAwait(false);
            await MyDataReportGlobal.GetData();
            DialogHost.CloseDialogCommand.Execute(new object(), sender);
            sender.IsEnabled = true;
        });
    }
}
